Persistent Volume
Here's the technical breakdown of using VirtualBox Shared Folders vs NFS for persistent storage in your k3s cluster:
1. Technical Possibility ✅
Yes, you can use VirtualBox Shared Folders as persistent storage through hostPath volumes, but with significant limitations compared to NFS.
2. Implementation Method
Step 1: Mount Shared Folder in VMs
# On both VM1 and VM2
sudo mount -t vboxsf <shared_folder_name> /mnt/sharedStep 2: Create PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: vbox-shared-pv
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
hostPath:
path: /mnt/shared
type: DirectoryStep 3: Create PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vbox-shared-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi3. Critical Limitations ⚠️
| Aspect | VirtualBox Shared Folders | NFS |
|---|---|---|
| Concurrent Access | Single-writer only | Multi-writer supported |
| File Locking | No proper advisory locks | Full locking support |
| Permissions | UID/GID mapping issues | POSIX permissions |
| Performance | Slow for small files | Better throughput |
| Pod Scheduling | Tied to specific nodes | Any node |
| Atomic Renames | Not supported | Supported |
| Symlinks | Partial support | Full support |
4. Specific Application Risks 🚨
- Database Corruption (Vaultwarden/PostgreSQL):
# Common error you might see: FATAL: could not flush dirty data: Invalid argument - File Locking Issues (Paperless-ngx/Nextcloud):
Error: Failed to acquire advisory lock on file - Permission Mismatches:
www-data user cannot write to shared folder
5. Recommended Workflow 🔄
If you still want to proceed:
- Use only for read-only volumes
- Add to pod specs:
securityContext: runAsUser: 1000 fsGroup: 1000 - Regular backups:
# Add to crontab 0 * * * * rsync -a /mnt/shared/ /mnt/backup/$(date +\%s)
6. Better Alternative ✅
Use NFS through VirtualBox Shared Folders:
- On Physical Machine 1:
# Share via NFS instead of vboxsf /mnt/host-share 192.168.123.221(rw,sync) 192.168.123.222(rw,sync) - Mount in VMs:
mount -t nfs 192.168.123.100:/mnt/host-share /mnt/nfs-share
7. When to Consider Shared Folders
- Single-node development clusters
- Read-only configmaps/secrets
- Temporary scratch space
- Non-critical data with regular backups
For your production-like home lab with stateful applications, NFS remains the better choice for data integrity and multi-node access.